package cn.comtom.ewbs.signature.common.config;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;

import cn.dev33.satoken.stp.StpUtil;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class LoginPageHandler implements HandlerInterceptor{

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		String uri = request.getRequestURI();
	    if (!StpUtil.isLogin() && !uri.contains("/auth/admin/login")) {
	        // 未登录，重定向到登录页
	        response.sendRedirect("/auth/admin/login");
	        return false;
	    }
	    return true;
	}

}
